package com.wc.AlgoOJ.CT0206;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/19 1:25
 * @description blg求最大and最小
 * http://43.138.190.70:8888/p/CT0206
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int n;
    static int N = 200000 + 7;
    static int[] a = new int[N];
    static int P = (int) 1e9 + 7;

    public static void main(String[] args) {
        n = sc.nextInt();
        // 正数的数量
        int posNum = 0;
        // 负数的数量
        int NegNum = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
            if (a[i] > 0)
                posNum++;
            else if (a[i] < 0)
                NegNum++;
        }
        // 只有一个数的情况
        if (n == 1) {
            System.out.println(a[1] + " " + a[1]);
            return;
        }
        Arrays.sort(a, 1, n + 1);

        // 全部都是0的情况
        if (posNum == 0 && NegNum == 0) {
            System.out.println("0 0");
            return;
        }

        long maxNum = 1;
        long minNum = a[1];
        // 将正数全部乘到最大值
        for (int i = 0; i < posNum; i++) {
            maxNum = maxNum * a[n - i] % P;
        }
        // 如果有负数的话就负数等于这个最大值，后面可以乘以这个负数变成最小值
        if (NegNum > 0) {
            minNum = maxNum;
        }
        // 取偶数个负数
        int r = NegNum / 2 * 2;

        // 用最大值乘以偶数个负数
        for (int i = 1; i <= r; i++) {
            maxNum = maxNum * a[i] % P;
        }
        // 取奇数个负数,让最小值乘以奇数个负数
        r = (NegNum % 2 == 0 ? NegNum - 1 : NegNum);
        for (int i = 1; i <= r; i++) {
            minNum = minNum * a[i] % P;
        }
        // 当只有正数且有0的情况
        if (NegNum == 0 && posNum < n) {
            minNum = 0;
        }
        // 当只有一个负数，且没有正数，有0的情况
        if (NegNum == 1 && posNum == 0 && n >= 2) {
            maxNum = 0;
        }

        System.out.println(minNum + " " + maxNum);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}